//
//  CRDiscoverController.m
//  CRChatRoom
//
//  Created by CuiFengshuai on 15/11/17.
//  Copyright © 2015年 SecondGroup. All rights reserved.
//

#import "CRDiscoverController.h"
#import "CRSetItem.h"
#import "CRSetGroup.h"
#import "CRSetArrowItem.h"
#import "CRHeaderView.h"
#import "CRNearPersonController.h"
#import "CREssenceViewController.h"
@interface CRDiscoverController () <CRHeaderViewDelegate>

@end

@implementation CRDiscoverController

#pragma mark >>>> 懒加载

#pragma mark >>>> 系统方法
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupGroup0];
    [self setupGroup1];

}


// 第0组数据
- (void)setupGroup0
{
    CRSetItem *item00 = [CRSetArrowItem itemWithIcon:@"iconfont-youxi" title:@"游戏" desvcClass:nil];
    CRSetItem *item01 = [CRSetArrowItem itemWithIcon:@"iconfont-yuedu" title:@"阅读" desvcClass:nil];
    CRSetItem *item02 = [CRSetArrowItem itemWithIcon:@"iconfont-yinle" title:@"音乐" desvcClass:nil];
    
    CRSetGroup *group0 = [[CRSetGroup alloc] init];
    group0.items = @[item00, item01, item02];
    [self.data addObject:group0];
}



// 第1组数据
- (void)setupGroup1
{
    CRSetItem *item10 = [CRSetArrowItem itemWithIcon:@"iconfont-fujin" title:@"附近的人" desvcClass:[CRNearPersonController class]];
    CRSetItem *item11 = [CRSetArrowItem itemWithIcon:@"iconfont-tongcheng" title:@"同城服务" desvcClass:nil];
    CRSetItem *item12 = [CRSetArrowItem itemWithIcon:@"iconfont-qun" title:@"直播间" desvcClass:nil];
    
    CRSetGroup *group1 = [[CRSetGroup alloc] init];
    group1.items = @[item10, item11, item12];
    [self.data addObject:group1];
}


// 头部大的view
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        CRHeaderView *hearView = [[CRHeaderView alloc] init];
        hearView.delegate = self;
        hearView.backgroundColor = [UIColor colorWithRed:0.053 green:0.272 blue:0.271 alpha:1.000];
        return hearView;
    }
    return nil;
}

// 头部view的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 130;
    }
    return 30;
}


#pragma mark >>>> headerView的代理方法
- (void)didClickButton:(ButtonType)type
{
    switch (type) {
        case ButtonTypeFriend:
            NSLog(@"friend");
        {
            
            
        }
            
            break;
        case ButtonTypeNear:
            NSLog(@"neae");
            
            break;
        case ButtonTypeHobby:{
            NSLog(@"hobb");
            CREssenceViewController *essVC = [[CREssenceViewController alloc] init];
            essVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:essVC animated:NO];
            
            break;
            
        }
        default:
            break;
    }
    
    
}




@end
